home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boostrs.arc / MBLKHEAP.ASM < prev    next >
Assembly Source File  |  1985-10-13  |  3KB  |  162 lines

  1. ;**********************************************
  2. ;
  3. ;       Procedure MBLKHEAP ( Page : HeapBuf;
  4. ;                              X1 : ColumnType;
  5. ;                              Y1 : RowType;
  6. ;                              X2 : ColumnType;
  7. ;                              Y2 : RowType;
  8. ;                              X3 : ColumnType;
  9. ;                              Y3 : RowType);
  10. ;       offset 18,16,14,12,10,08,06,04  from BP
  11. ;
  12. ;       Moves block on Page at X1,Y1,X2,Y2
  13. ;                           to X3,Y3
  14. ;**********************************************
  15. MBLKHEAP proc    near
  16.         push    bp
  17.     mov    bp,sp
  18.     push    ds
  19. ;
  20. ;
  21. ;*** Compute number of lines to move
  22. ;
  23.     mov    ax,[bp+12]    ; Y1
  24.     mov    cx,[bp+08]    ; Y2
  25.         sub     cx,ax           ; CX = Y2 - Y1
  26.     inc    cx        ; Number of lines
  27. ;
  28. ;
  29. ;*** Compute length of each move
  30. ;
  31.     mov    ax,[bp+14]    ;  X1
  32.     mov    dx,[bp+10]    ;  X2
  33.     sub    dx,ax        ;  DX = X2 - X1
  34.     inc    dx        ;  num WORDS/line
  35.     shl    dx,1        ;  num bytes/line
  36.     mov    bx,cx
  37. ;
  38. ;*** Compute workspace needed on stack
  39. ;
  40. wksp:    sub    sp,dx
  41.     loop    wksp
  42. ;
  43.     mov    ax,ss
  44.     mov    es,ax
  45.     mov    di,sp        ;  ES:DI has stack address
  46.     push    dx
  47.     push    bx
  48.  
  49. ;
  50. ;*** Determine Page segment and offset addresses
  51. ;
  52.     mov    si,[bp+16]
  53.     mov    ax,[bp+18]
  54.     mov    ds,ax
  55. ;
  56. ;*** Compute X,Y offset with page
  57. ;
  58.     add    si,[bp+12]    ;  Y1
  59.         dec     si              ;  (Y1-1)
  60.     mov    dx,si        ;  Save in DX
  61.     mov    cl,7
  62.     shl    dx,cl        ;  (Y1-1) * 128
  63.     mov    cl,5
  64.     shl    si,cl        ;  (Y1-1) *  32
  65.     add    si,dx        ;  (Y1-1) * 160
  66.     mov    ax,[bp+14]    ;  X1
  67.     dec    ax        ;  (X1-1)
  68.     shl    ax,1        ;  2 * (X1-1)
  69.     add    si,ax        ;  SI = up left off
  70. ;
  71.     pop    dx        ; Number of lines
  72.     pop    cx        ; Bytes/line
  73.     shr    cx,1        ; Words/line
  74.     push    ds
  75.     push    si
  76. ;
  77.     push    dx
  78.     push    cx
  79. ;
  80. ;*** Move block from page to stack
  81. ;
  82.     mov    ax,160
  83.     sub    ax,cx
  84.     sub    ax,cx
  85.     cld
  86. MOVE1:  push    cx
  87. rep    movsw
  88. ;
  89.     pop    cx
  90.     dec    dx
  91.     jz    DONE1
  92.     add    si,ax
  93.     jmp    MOVE1
  94. ;
  95. ;*** Blank object on page
  96. ;
  97. DONE1:  pop     cx
  98.     pop    dx
  99.     pop    di
  100.     pop    es
  101.     push    dx
  102.     push    cx
  103.     mov    bx,160
  104.     sub    bx,cx
  105.     sub    bx,cx
  106.         mov     ax,0E20h
  107.     cld
  108. AGAIN:    push    cx
  109. rep    stosw
  110. ;
  111.     pop    cx
  112.     dec    dx
  113.     jz    DONE2
  114.     add    di,bx
  115.     jmp    AGAIN
  116. ;
  117. ;*** Move saved object from stack workspace
  118. ;*** to new location on page
  119. ;
  120. DONE2:    mov    di,[bp+16]    ;  page offset
  121.     add    di,[bp+04]    ;  add Y3 offset
  122.         dec     di              ;  (Y3-1)
  123.     mov    dx,di        ;  Save in DX
  124.     mov    cl,7
  125.     shl    dx,cl        ;  (Y3-1) * 128
  126.     mov    cl,5
  127.     shl    di,cl        ;  (Y3-1) *  32
  128.     add    di,dx        ;  (Y3-1) * 160
  129.     mov    ax,[bp+06]    ;  X3 into AX
  130.     dec    ax        ;  (X3-1)
  131.     shl    ax,1        ;  2 * (X3-1)
  132.     add    di,ax        ;  DI=up left of new loc
  133. ;
  134. ;*** Move block
  135. ;
  136.     pop    cx
  137.     pop    dx
  138.         mov     si,sp
  139.     mov    ax,ss
  140.     mov    ds,ax
  141. ;
  142.     mov    ax,160
  143.     sub    ax,cx
  144.     sub    ax,cx
  145.     cld
  146. MOVER:  push    cx
  147. rep    movsw
  148. ;
  149.     pop    cx
  150.     dec    dx
  151.     jz    DONE3
  152.     add    di,ax
  153.         jmp     MOVER
  154. ;
  155. DONE3:    mov    sp,bp
  156.     sub    sp,2
  157.         pop     ds
  158.         mov     sp,bp
  159.         pop     bp
  160.     ret    16
  161. MBLKHEAP endp
  162.